package cn.kailangtu.dataspot.data;

import java.util.ArrayList;
import java.util.List;

import android_serialport_api.SerialPortFinder;
import cn.kailangtu.commonevents.data.DataBean;
import cn.kailangtu.dataspot.R;

public class ControlTree {


    private  ControlTreeNode rootNode;
    private ControlTreeNode selectNode;

    public ControlTreeNode getRootNode() {
        return rootNode;
    }

    public void setRootNode(ControlTreeNode rootNode) {
        this.rootNode = rootNode;
    }

    public ControlTreeNode getSelectNode() {
        return selectNode;
    }

    public void setSelectNode(ControlTreeNode selectNode) {
        this.selectNode = selectNode;
    }

    private static ControlTree LowDataControlTree;
    private static ControlTree LowCommonSettingControlTree;
    private static ControlTree LowExceptionLog;
    private static ControlTree LowFactorySetting;
    private static ControlTree LowSwitch;
    private static ControlTree DataControlTree;
    private static ControlTree CommonSettingControlTree;
    private static ControlTree ExceptionLog;
    private static ControlTree FactorySetting;
    private static ControlTree Switch;


    public static ControlTree getLowDataControlTree()
    {
        if(LowDataControlTree == null)
        {
            LowDataControlTree = new ControlTree();
            ControlTreeNode root = new ControlTreeNode();
            root.setLevel(0);


            LowDataControlTree.setRootNode(root);


        }
        return LowDataControlTree;
    }


    public static ControlTree getLowCommonSettingControlTree(){
        List<DataBean<Integer>> ls11 = new ArrayList<>();
        ls11.add(new DataBean<>("3300V",0));
        ls11.add(new DataBean<>("1140V",1));
        ls11.add(new DataBean<>("660V",2));
        ls11.add(new DataBean<>("380V",3));

        List<DataBean<Integer>> ls13 = new ArrayList<>();
        ls13.add(new DataBean<>("630A/1V",0));
        ls13.add(new DataBean<>("1000A/1V",1));
        ls13.add(new DataBean<>("1250A/1V",2));
        ls13.add(new DataBean<>("1600A/1V",3));
        ls13.add(new DataBean<>("2000A/1V",4));

        List<DataBean<Integer>> ls21 = new ArrayList<>();
        ls21.add(new DataBean<>("关",0));
        ls21.add(new DataBean<>("反时限",1));
        ls21.add(new DataBean<>("定时限",2));

        List<DataBean<Integer>> ls31 = new ArrayList<>();
        ls31.add(new DataBean<>("关",0));
        ls31.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls41 = new ArrayList<>();
        ls41.add(new DataBean<>("关",0));
        ls41.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls51 = new ArrayList<>();
        ls51.add(new DataBean<>("关",0));
        ls51.add(new DataBean<>("开",1));

//        List<DataBean<Integer>> ls52 = new ArrayList<>();
//        ls52.add(new DataBean<>("闭动",0));
//        ls52.add(new DataBean<>("开动",1));
        List<DataBean<Integer>> ls52 = new ArrayList<>();
        ls52.add(new DataBean<>("开动",0));
        ls52.add(new DataBean<>("闭动",1));

        List<DataBean<Integer>> ls61 = new ArrayList<>();
        ls61.add(new DataBean<>("关",0));
        ls61.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls71 = new ArrayList<>();
        ls71.add(new DataBean<>("关",0));
        ls71.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls81 = new ArrayList<>();
        ls81.add(new DataBean<>("关",0));
        ls81.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls82 = new ArrayList<>();
        ls82.add(new DataBean<>("关",0));
        ls82.add(new DataBean<>("开",1));

//        List<DataBean<Integer>> ls91 = new ArrayList<>();
//        ls91.add(new DataBean<>("闭动",0));
//        ls91.add(new DataBean<>("开动",1));
        List<DataBean<Integer>> ls91 = new ArrayList<>();
        ls91.add(new DataBean<>("开动",0));
        ls91.add(new DataBean<>("闭动",1));

//        List<DataBean<Integer>> ls93 = new ArrayList<>();
//        ls93.add(new DataBean<>("闭动",0));
//        ls93.add(new DataBean<>("开动",1));
        List<DataBean<Integer>> ls93 = new ArrayList<>();
        ls93.add(new DataBean<>("开动",0));
        ls93.add(new DataBean<>("闭动",1));

        List<DataBean<Integer>> ls94 = new ArrayList<>();
        ls94.add(new DataBean<>("关",0));
        ls94.add(new DataBean<>("开",1));
        List<DataBean<Integer>> ls95 = new ArrayList<>();
        ls95.add(new DataBean<>("关",0));
        ls95.add(new DataBean<>("开",1));
        List<DataBean<Integer>> lsA1 = new ArrayList<>();
        lsA1.add(new DataBean<>("开动",0));
        lsA1.add(new DataBean<>("闭动",1));
        List<DataBean<Integer>> lsA3 = new ArrayList<>();
        lsA3.add(new DataBean<>("开动",0));
        lsA3.add(new DataBean<>("闭动",1));

        List<DataBean<Integer>> lsB1 = new ArrayList<>();
        lsB1.add(new DataBean<>("短路防越级",0));
        lsB1.add(new DataBean<>("漏电防越级",1));

        List<DataBean<Integer>> lsB3 = new ArrayList<>();
        lsB3.add(new DataBean<>("一级",0));
        lsB3.add(new DataBean<>("二级",1));
        lsB3.add(new DataBean<>("三级",2));
        lsB3.add(new DataBean<>("四级",3));

        List<DataBean<Integer>> lsB4 = new ArrayList<>();
        lsB4.add(new DataBean<>("关",0));
        lsB4.add(new DataBean<>("开",1));

        List<DataBean<Integer>> lsC1 = new ArrayList<>();
        lsC1.add(new DataBean<>("关",0));
        lsC1.add(new DataBean<>("PT100",1));
        lsC1.add(new DataBean<>("闭动",2));
        lsC1.add(new DataBean<>("开动",3));

        List<DataBean<Integer>> lsC4 = new ArrayList<>();
        lsC4.add(new DataBean<>("关",0));
        lsC4.add(new DataBean<>("开",1));

        if(LowCommonSettingControlTree == null)
        {
            LowCommonSettingControlTree = new ControlTree();

            ControlTreeNode root = new ControlTreeNode(0);
            LowCommonSettingControlTree.setRootNode(root);

            ControlTreeNode node1  =new ControlTreeNode(1,R.id.tvCommonSettingTitle1Low,0,root);
            ControlTreeNode node11  =new ControlTreeNode(2,R.id.tvCommonSettingTitle11Low,R.id.tvCommonSettingValue11Low,node1,ls11,0,4500,"额定电压");
            ControlTreeNode node12  =new ControlTreeNode(2,R.id.tvCommonSettingTitle12Low,R.id.tvCommonSettingValue12Low,node1,null,0,4501,"整定电流");
            ControlTreeNode node13  =new ControlTreeNode(2,R.id.tvCommonSettingTitle13Low,R.id.tvCommonSettingValue13Low,node1,ls13,0,4502,"互感器");
            ControlTreeNode node2 =new ControlTreeNode(1,R.id.tvCommonSettingTitle2Low,0,root);
            ControlTreeNode node21  =new ControlTreeNode(2,R.id.tvCommonSettingTitle21Low,R.id.tvCommonSettingValue21Low,node2,ls21,0,4509,"过载选择");
            ControlTreeNode node22  =new ControlTreeNode(2,R.id.tvCommonSettingTitle22Low,R.id.tvCommonSettingValue22Low,node2,null,2,4510,"定时限过载倍数",0.1f,10);
            ControlTreeNode node23  =new ControlTreeNode(2,R.id.tvCommonSettingTitle23Low,R.id.tvCommonSettingValue23Low,node2,null,0,4511,"定时限过载延时");
            ControlTreeNode node3  =new ControlTreeNode(1,R.id.tvCommonSettingTitle3Low,0,root);
            ControlTreeNode node31  =new ControlTreeNode(2,R.id.tvCommonSettingTitle31Low,R.id.tvCommonSettingValue31Low,node3,ls31,0,4503,"短路开关");
            ControlTreeNode node32  =new ControlTreeNode(2,R.id.tvCommonSettingTitle32Low,R.id.tvCommonSettingValue32Low,node3,null,2,4504,"短路倍数",0.1f,10);
            ControlTreeNode node33  =new ControlTreeNode(2,R.id.tvCommonSettingTitle33Low,R.id.tvCommonSettingValue33Low,node3,null,0,4505,"短路延时",0,5000);
            ControlTreeNode node4 =new ControlTreeNode(1,R.id.tvCommonSettingTitle4Low,0,root);
            ControlTreeNode node41  =new ControlTreeNode(2,R.id.tvCommonSettingTitle41Low,R.id.tvCommonSettingValue41Low,node4,ls41,0,4512,"不平衡保护");
            ControlTreeNode node42  =new ControlTreeNode(2,R.id.tvCommonSettingTitle42Low,R.id.tvCommonSettingValue42Low,node4,null,0,4513,"不平衡系数",10,100);
            ControlTreeNode node43  =new ControlTreeNode(2,R.id.tvCommonSettingTitle43Low,R.id.tvCommonSettingValue43Low,node4,null,0,4514,"不平衡延时",0,500);
            ControlTreeNode node5  =new ControlTreeNode(1,R.id.tvCommonSettingTitle5Low,0,root);
            ControlTreeNode node51  =new ControlTreeNode(2,R.id.tvCommonSettingTitle51Low,R.id.tvCommonSettingValue51Low,node5,ls51,0,4515,"低压侧故障开关");
            ControlTreeNode node52  =new ControlTreeNode(2,R.id.tvCommonSettingTitle52Low,R.id.tvCommonSettingValue52Low,node5,ls52,0,4516,"低压侧故障选择");
            ControlTreeNode node53  =new ControlTreeNode(2,R.id.tvCommonSettingTitle53Low,R.id.tvCommonSettingValue53Low,node5,null,0,4517,"动作延时",0,1000);
            /*****6*****/
            ControlTreeNode node6  =new ControlTreeNode(1,R.id.tvCommonSettingTitle6Low,0,root);
            ControlTreeNode node61  =new ControlTreeNode(2,R.id.tvCommonSettingTitle61Low,R.id.tvCommonSettingValue61Low,node6,ls61,0,4518,"过压开关");
            ControlTreeNode node62  =new ControlTreeNode(2,R.id.tvCommonSettingTitle62Low,R.id.tvCommonSettingValue62Low,node6,null,0,4519,"过压系数",100,140);
            ControlTreeNode node63  =new ControlTreeNode(2,R.id.tvCommonSettingTitle63Low,R.id.tvCommonSettingValue63Low,node6,null,0,4520,"过压延时",0,200);
            /*****7*****/
            ControlTreeNode node7  =new ControlTreeNode(1,R.id.tvCommonSettingTitle7Low,0,root);
            ControlTreeNode node71  =new ControlTreeNode(2,R.id.tvCommonSettingTitle71Low,R.id.tvCommonSettingValue71Low,node7,ls71,0,4521,"欠压保护");
            ControlTreeNode node72  =new ControlTreeNode(2,R.id.tvCommonSettingTitle72Low,R.id.tvCommonSettingValue72Low,node7,null,0,4522,"欠压系数",65,100);
            ControlTreeNode node73  =new ControlTreeNode(2,R.id.tvCommonSettingTitle73Low,R.id.tvCommonSettingValue73Low,node1,null,0,4523,"欠压延时");


            /*****8*****/

            ControlTreeNode node8  =new ControlTreeNode(1,R.id.tvCommonSettingTitle8Low,0,root);
            ControlTreeNode node81  =new ControlTreeNode(2,R.id.tvCommonSettingTitle81Low,R.id.tvCommonSettingValue81Low,node8,ls81,0,4537,"绝缘监视");
            ControlTreeNode node82  =new ControlTreeNode(2,R.id.tvCommonSettingTitle82Low,R.id.tvCommonSettingValue82Low,node8,ls82,0,4538,"绝缘保护");
            ControlTreeNode node83  =new ControlTreeNode(2,R.id.tvCommonSettingTitle83Low,R.id.tvCommonSettingValue83Low,node8,null,0,4539,"动作延时",0,200);
            /*****9*****/
            ControlTreeNode node9  =new ControlTreeNode(1,R.id.tvCommonSettingTitle9Low,0,root);
            ControlTreeNode node91  =new ControlTreeNode(2,R.id.tvCommonSettingTitle91Low,R.id.tvCommonSettingValue91Low,node9,ls91,0,4530,"温度选择");
            ControlTreeNode node92  =new ControlTreeNode(2,R.id.tvCommonSettingTitle92Low,R.id.tvCommonSettingValue92Low,node9,null,0,4531,"温度设置",0,200);
            ControlTreeNode node93  =new ControlTreeNode(2,R.id.tvCommonSettingTitle93Low,R.id.tvCommonSettingValue93Low,node9,ls93,0,4532,"动作延时");
            ControlTreeNode node94  =new ControlTreeNode(2,R.id.tvCommonSettingTitle94Low,R.id.tvCommonSettingValue94Low,node9,null,0,4533,"接线柱温度保护",0,200);
            ControlTreeNode node95  =new ControlTreeNode(2,R.id.tvCommonSettingTitle95Low,R.id.tvCommonSettingValue95Low,node9,ls95,0,4508,"接线柱温度保护");


            /****B*****/
            ControlTreeNode nodeB  =new ControlTreeNode(1,R.id.tvCommonSettingTitleBLow,0,root);
            ControlTreeNode nodeB1  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB1Low,R.id.tvCommonSettingValueB1Low,nodeB,lsB1,3,5555,"类型");
            ControlTreeNode nodeB2  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB2Low,R.id.tvCommonSettingValueB2Low,nodeB,null,3,true);
            ControlTreeNode nodeB3  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB3Low,R.id.tvCommonSettingValueB3Low,nodeB,lsB3,3,5555,"级数");
            ControlTreeNode nodeB4  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB4Low,R.id.tvCommonSettingValueB4Low,nodeB,lsB4,3,5555,"防越级保护",0,200);



            /*****C*****/
            ControlTreeNode nodeC  =new ControlTreeNode(1,R.id.tvCommonSettingTitleCLow,0,root);
            ControlTreeNode nodeC1  =new ControlTreeNode(2,R.id.tvCommonSettingTitleC1Low,R.id.tvCommonSettingValueC1Low,nodeC,lsC1,0,4524,"温度选择");
            ControlTreeNode nodeC2  =new ControlTreeNode(2,R.id.tvCommonSettingTitleC2Low,R.id.tvCommonSettingValueC2Low,nodeC,null,0,4525,"温度设置",50,200);
            ControlTreeNode nodeC3  =new ControlTreeNode(2,R.id.tvCommonSettingTitleC3Low,R.id.tvCommonSettingValueC3Low,nodeC,null,0,4526,"动作延时",0,200);
            ControlTreeNode nodeC4  =new ControlTreeNode(2,R.id.tvCommonSettingTitleC4Low,R.id.tvCommonSettingValueC4Low,nodeC,lsC4,0,4527,"接线柱温度保护");
            ControlTreeNode nodeC5  =new ControlTreeNode(2,R.id.tvCommonSettingTitleC5Low,R.id.tvCommonSettingValueC5Low,nodeC,null,0,4528,"接线柱温设置",50,200);
            ControlTreeNode nodeC6  =new ControlTreeNode(2,R.id.tvCommonSettingTitleC6Low,R.id.tvCommonSettingValueC6Low,nodeC,null,0,4529,"动作延时",0,200);



            ControlTreeNode[] root1Children =new ControlTreeNode[]{node11,node12,node13};
            ControlTreeNode[] root2Children = new ControlTreeNode[]{node21,node22,node23};
            ControlTreeNode[] root3Children =new ControlTreeNode[]{node31,node32,node33};
            ControlTreeNode[] root4Children =new ControlTreeNode[]{node41,node42,node43};
            ControlTreeNode[] root5Children = new ControlTreeNode[]{node51,node52,node53};
            ControlTreeNode[] root6Children = new ControlTreeNode[]{node61,node62,node63};
            ControlTreeNode[] root7Children = new ControlTreeNode[]{node71,node72,node73};
            ControlTreeNode[] root8Children =new ControlTreeNode[]{node81,node82,node83};
            ControlTreeNode[] root9Children =new ControlTreeNode[]{node91,node92,node93,node94,node95};
            ControlTreeNode[] rootBChildren = new ControlTreeNode[]{nodeB1,nodeB2,nodeB3,nodeB4};
            ControlTreeNode[] rootCChildren = new ControlTreeNode[]{nodeC1,nodeC2,nodeC3,nodeC4,nodeC5,nodeC6};

            ControlTreeNode[] rootChildren = new ControlTreeNode[]{node1,node2,node3,node4,node5,node6,node7,node8,node9,nodeB,nodeC};

            setLeftAndRight(root1Children);
            setLeftAndRight(root2Children);
            setLeftAndRight(root3Children);
            setLeftAndRight(root4Children);
            setLeftAndRight(root5Children);
            setLeftAndRight(root6Children);
            setLeftAndRight(root7Children);
            setLeftAndRight(root8Children);
            setLeftAndRight(root9Children);
            setLeftAndRight(rootBChildren);
            setLeftAndRight(rootCChildren);
            setLeftAndRight(rootChildren);

            addChild(node1,root1Children);
            addChild(node2,root2Children);
            addChild(node3,root3Children);
            addChild(node4,root4Children);
            addChild(node5,root5Children);
            addChild(node6,root6Children);
            addChild(node7,root7Children);
            addChild(node8,root8Children);
            addChild(node9,root9Children);
            addChild(nodeB,rootBChildren);
            addChild(nodeC,rootCChildren);
            addChild(root,rootChildren);

        }
        return LowCommonSettingControlTree;
    }


    public static ControlTree getLowExceptionLog()
    {
        if(LowExceptionLog == null){
            LowExceptionLog = new ControlTree();

            ControlTreeNode root = new ControlTreeNode(0);
            ControlTreeNode leftButton =new ControlTreeNode(1,R.id.btnExceptionLogPreviewLow,0,root);

            ControlTreeNode rightButton =new ControlTreeNode(1,R.id.btnExceptionLogNextLow,0,root);


            leftButton.setRight(rightButton);
            rightButton.setLeft(leftButton);


            root.addChild(leftButton);
            root.addChild(rightButton);

            LowExceptionLog.setRootNode(root);
        }

        return LowExceptionLog;
    }

    public static ControlTree getLowFactorySetting(){
        List<DataBean<Integer>> ls25 = new ArrayList<>();
        ls25.add(new DataBean<>("1200",1200));
        ls25.add(new DataBean<>("2400",2400));
        ls25.add(new DataBean<>("4800",4800));
        ls25.add(new DataBean<>("9600",9600));
        ls25.add(new DataBean<>("19200",19200));
        ls25.add(new DataBean<>("38400",38400));




        List<DataBean<Integer>> ls52 = new ArrayList<>();
        ls52.add(new DataBean<>("38400",0));
        ls52.add(new DataBean<>("19200",1));
        ls52.add(new DataBean<>("9600",2));
        ls52.add(new DataBean<>("4800",3));
        ls52.add(new DataBean<>("2400",4));
        ls52.add(new DataBean<>("1200",5));

        List<DataBean<Integer>> ls53 = new ArrayList<>();
        ls53.add(new DataBean<>("无",0));
        ls53.add(new DataBean<>("偶",1));
        ls53.add(new DataBean<>("奇",2));

        List<DataBean<Integer>> ls54 = new ArrayList<>();
        ls54.add(new DataBean<>("本机",0));
        ls54.add(new DataBean<>("通讯",1));

        List<DataBean<Integer>> ls26 = new ArrayList<>();
        ls26.add(new DataBean<>("关",0));
        ls26.add(new DataBean<>("开",1));


        if(LowFactorySetting == null){
            LowFactorySetting = new ControlTree();
            ControlTreeNode root = new ControlTreeNode(0);
            ControlTreeNode node1  =new ControlTreeNode(1,R.id.tvFactorySettingTitle1Low,0,root);
            ControlTreeNode node11  =new ControlTreeNode(2,R.id.tvFactorySettingTitle11Low,R.id.tvFactorySettingValueOne11Low,node1,null,0,4570,"系统电压微调",50,100);
            ControlTreeNode node12  =new ControlTreeNode(2,R.id.tvFactorySettingTitle12Low,R.id.tvFactorySettingValueOne12Low,node1,null,0,4571,"A相电流微调",50,100);
            ControlTreeNode node13  =new ControlTreeNode(2,R.id.tvFactorySettingTitle13Low,R.id.tvFactorySettingValueOne13Low,node1,null,0,4572,"B相电流微调",50,100);
            ControlTreeNode node14  =new ControlTreeNode(2,R.id.tvFactorySettingTitle14Low,R.id.tvFactorySettingValueOne14Low,node1,null,0,4573,"C相电流微调",50,100);
            ControlTreeNode node15  =new ControlTreeNode(2,R.id.tvFactorySettingTitle15Low,R.id.tvFactorySettingValueOne15Low,node1,null,0,4574,"温度微调",50,100);

            ControlTreeNode node2  =new ControlTreeNode(1,R.id.tvFactorySettingTitle2Low,0,root);
            ControlTreeNode node21  =new ControlTreeNode(2,R.id.tvFactorySettingTitle21Low,R.id.tvFactorySettingValue21Low,node2,null,3,true);
            ControlTreeNode node22  =new ControlTreeNode(2,R.id.tvFactorySettingTitle22Low,R.id.tvFactorySettingValue22Low,node2,null,3,true);
            ControlTreeNode node23  =new ControlTreeNode(2,R.id.tvFactorySettingTitle23Low,R.id.tvFactorySettingValue23Low,node2,null,3,true);
            ControlTreeNode node24  =new ControlTreeNode(2,R.id.tvFactorySettingTitle24Low,R.id.tvFactorySettingValue24Low,node2,null,3);
            ControlTreeNode node25  =new ControlTreeNode(2,R.id.tvFactorySettingTitle25Low,R.id.tvFactorySettingValue25Low,node2,null,3,true);
            ControlTreeNode node26  =new ControlTreeNode(2,R.id.tvFactorySettingTitle26Low,R.id.tvFactorySettingValue26Low,node2,ls26,3,true);

            ControlTreeNode node3  =new ControlTreeNode(1,R.id.tvFactorySettingTitle3Low,0,root);
            ControlTreeNode node31  =new ControlTreeNode(2,R.id.tvFactorySettingTitle31Low,R.id.tvFactorySettingValue31Low,node3,getDeviceList(),3,true);
            ControlTreeNode node32  =new ControlTreeNode(2,R.id.tvFactorySettingTitle32Low,R.id.tvFactorySettingValue32Low,node3,getBaud(),3,true);
            ControlTreeNode node33  =new ControlTreeNode(2,R.id.tvFactorySettingTitle33Low,R.id.tvFactorySettingValue33Low,node3,getCheck(),3,true);
            ControlTreeNode node34  =new ControlTreeNode(2,R.id.tvFactorySettingTitle34Low,R.id.tvFactorySettingValue34Low,node3,getDeviceList(),3);
            ControlTreeNode node35  =new ControlTreeNode(2,R.id.tvFactorySettingTitle35Low,R.id.tvFactorySettingValue35Low,node3,getBaud(),3);
            ControlTreeNode node36  =new ControlTreeNode(2,R.id.tvFactorySettingTitle36Low,R.id.tvFactorySettingValue36Low,node3,getCheck(),3);
            ControlTreeNode node37  =new ControlTreeNode(2,R.id.tvFactorySettingTitle37Low,R.id.tvFactorySettingValue37Low,node3,null,3);

            ControlTreeNode node4  =new ControlTreeNode(1,R.id.tvFactorySettingTitle4Low,0,root);
            ControlTreeNode node41  =new ControlTreeNode(2,R.id.tvFactorySettingTitle41Low,0,node4,null,5);
            ControlTreeNode node42  =new ControlTreeNode(2,R.id.tvFactorySettingTitle42Low,0,node4,null,5);
            ControlTreeNode node43  =new ControlTreeNode(2,R.id.tvFactorySettingTitle43Low,0,node4,null,5);
            ControlTreeNode node44  =new ControlTreeNode(2,R.id.tvFactorySettingTitle44Low,0,node4,null,5);
            ControlTreeNode node45  =new ControlTreeNode(2,R.id.tvFactorySettingTitle45Low,0,node4,null,5);




            ControlTreeNode node5  =new ControlTreeNode(1,R.id.tvFactorySettingTitle5Low,0,root);
            ControlTreeNode node51  =new ControlTreeNode(2,R.id.tvFactorySettingTitle51Low,R.id.tvFactorySettingValue51Low,node5,null,0,4550,"485站地址",1,250);
            ControlTreeNode node52  =new ControlTreeNode(2,R.id.tvFactorySettingTitle52Low,R.id.tvFactorySettingValue52Low,node5,ls52,0,4551,"波特率");
            ControlTreeNode node53  =new ControlTreeNode(2,R.id.tvFactorySettingTitle53Low,R.id.tvFactorySettingValue53Low,node5,ls53,0,4552,"校验");
            ControlTreeNode node54  =new ControlTreeNode(2,R.id.tvFactorySettingTitle54Low,R.id.tvFactorySettingValue54Low,node5,ls54,0,4553,"远程控制开关");


            ControlTreeNode node6  =new ControlTreeNode(1,R.id.tvFactorySettingTitle6Low,0,root);
            ControlTreeNode node61  =new ControlTreeNode(2,R.id.tvFactorySettingTitle61Low,0,node6,null,5);
            ControlTreeNode node62  =new ControlTreeNode(2,R.id.tvFactorySettingTitle62Low,0,node6,null,5);


            ControlTreeNode[] rootChildren = new ControlTreeNode[]{node1,node2,node3,node4,node5,node6};
            ControlTreeNode[] node1Children = new ControlTreeNode[]{node11,node12,node13,node14,node15};
            ControlTreeNode[] node2Children = new ControlTreeNode[]{node21,node22,node23,node24,node25,node26};
            ControlTreeNode[] node3Children = new ControlTreeNode[]{node31,node32,node33,node34,node35,node36,node37};
            ControlTreeNode[] node4Children = new ControlTreeNode[]{node41,node42,node43,node44,node45};
            ControlTreeNode[] node5Children = new ControlTreeNode[]{node51,node52,node53,node54};
            ControlTreeNode[] node6Children = new ControlTreeNode[]{node61,node62};


            setLeftAndRight(node1Children);
            setLeftAndRight(node2Children);
            setLeftAndRight(node3Children);
            setLeftAndRight(node4Children);
            setLeftAndRight(node5Children);
            setLeftAndRight(node6Children);

            setLeftAndRight(rootChildren);

            addChild(node1,node1Children);
            addChild(node2,node2Children);
            addChild(node3,node3Children);
            addChild(node4,node4Children);
            addChild(node5,node5Children);
            addChild(node6,node6Children);

            addChild(root,rootChildren);


            LowFactorySetting.setRootNode(root);
        }
        return LowFactorySetting;
    }

    public static ControlTree getLowSwitch(){
        if(LowSwitch == null){
            LowSwitch = new ControlTree();
            ControlTreeNode root = new ControlTreeNode();
            root.setLevel(0);
            LowSwitch.setRootNode(root);


            ControlTreeNode controlTreeNode1 = new ControlTreeNode(1,R.id.tvSwitchTestTitleLow1,0,root,3595,"开关合闸",true,2);
            ControlTreeNode controlTreeNode2 = new ControlTreeNode(1,R.id.tvSwitchTestTitleLow2,0,root,3595,"开关分闸",true,4);
            ControlTreeNode controlTreeNode3 = new ControlTreeNode(1,R.id.tvSwitchTestTitleLow3,0,root,3595,"短路试验",true,16);
            ControlTreeNode controlTreeNode4 = new ControlTreeNode(1,R.id.tvSwitchTestTitleLow4,0,root,3595,"过载试验",true,32);
            ControlTreeNode controlTreeNode5 = new ControlTreeNode(1,R.id.tvSwitchTestTitleLow5,0,root,3595,"漏电试验",true,8);
            ControlTreeNode controlTreeNode6 = new ControlTreeNode(1,R.id.tvSwitchTestTitleLow6,0,root);

            ControlTreeNode[] rootChildren = new ControlTreeNode[]{controlTreeNode1,controlTreeNode2,controlTreeNode3,controlTreeNode4,controlTreeNode5,controlTreeNode6};
            setLeftAndRight(rootChildren);
            addChild(root,rootChildren);

        }
        return LowSwitch;
    }


    public static ControlTree getDataControlTree()
    {
        if(DataControlTree == null)
        {
            DataControlTree = new ControlTree();
            ControlTreeNode root = new ControlTreeNode(0);
            DataControlTree.setRootNode(root);
        }
        return DataControlTree;
    }

    public static ControlTree getCommonSettingControlTree(){

        List<DataBean<Integer>> ls11 = new ArrayList<>();
        ls11.add(new DataBean<>("10000V",0));
        ls11.add(new DataBean<>("6000V",1));

        List<DataBean<Integer>> ls13 = new ArrayList<>();
        ls13.add(new DataBean<>("100A/1V",0));
        ls13.add(new DataBean<>("200A/1V",1));
        ls13.add(new DataBean<>("400A/1V",2));
        ls13.add(new DataBean<>("630A/1V",3));

        List<DataBean<Integer>> ls21 = new ArrayList<>();
        ls21.add(new DataBean<>("关",0));
        ls21.add(new DataBean<>("反时限",1));
        ls21.add(new DataBean<>("定时限",2));

        List<DataBean<Integer>> ls31 = new ArrayList<>();
        ls31.add(new DataBean<>("关",0));
        ls31.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls41 = new ArrayList<>();
        ls41.add(new DataBean<>("关",0));
        ls41.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls51 = new ArrayList<>();
        ls51.add(new DataBean<>("关",0));
        ls51.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls52 = new ArrayList<>();
        ls52.add(new DataBean<>("开动",0));
        ls52.add(new DataBean<>("闭动",1));

        List<DataBean<Integer>> ls61 = new ArrayList<>();
        ls61.add(new DataBean<>("关",0));
        ls61.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls71 = new ArrayList<>();
        ls71.add(new DataBean<>("关",0));
        ls71.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls81 = new ArrayList<>();
        ls81.add(new DataBean<>("关",0));
        ls81.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls82 = new ArrayList<>();
        ls82.add(new DataBean<>("关",0));
        ls82.add(new DataBean<>("开",1));

        List<DataBean<Integer>> ls91 = new ArrayList<>();
        ls91.add(new DataBean<>("关",0));
        ls91.add(new DataBean<>("PT100",1));
        ls91.add(new DataBean<>("闭动",2));
        ls91.add(new DataBean<>("开动",3));

        List<DataBean<Integer>> ls94 = new ArrayList<>();
        ls94.add(new DataBean<>("关",0));
        ls94.add(new DataBean<>("开",1));

//        List<DataBean<Integer>> lsA1 = new ArrayList<>();
//        lsA1.add(new DataBean<>("闭动",0));
//        lsA1.add(new DataBean<>("开动",1));
        List<DataBean<Integer>> lsA1 = new ArrayList<>();
        lsA1.add(new DataBean<>("开动",0));
        lsA1.add(new DataBean<>("闭动",1));

//        List<DataBean<Integer>> lsA3 = new ArrayList<>();
//        lsA3.add(new DataBean<>("闭动",0));
//        lsA3.add(new DataBean<>("开动",1));
        List<DataBean<Integer>> lsA3 = new ArrayList<>();
        lsA3.add(new DataBean<>("开动",0));
        lsA3.add(new DataBean<>("闭动",1));


        List<DataBean<Integer>> lsB1 = new ArrayList<>();
        lsB1.add(new DataBean<>("短路防越级",0));
        lsB1.add(new DataBean<>("漏电防越级",1));

        List<DataBean<Integer>> lsB3 = new ArrayList<>();
        lsB3.add(new DataBean<>("一级",0));
        lsB3.add(new DataBean<>("二级",1));
        lsB3.add(new DataBean<>("三级",2));
        lsB3.add(new DataBean<>("四级",3));

        List<DataBean<Integer>> lsB4 = new ArrayList<>();
        lsB4.add(new DataBean<>("关",0));
        lsB4.add(new DataBean<>("开",1));

        List<DataBean<Integer>> lsA5 = new ArrayList<>();
        lsA5.add(new DataBean<>("关",0));
        lsA5.add(new DataBean<>("开",1));

        if(CommonSettingControlTree == null)
        {
            CommonSettingControlTree = new ControlTree();

            ControlTreeNode root = new ControlTreeNode(0);
            CommonSettingControlTree.setRootNode(root);

            ControlTreeNode node1  =new ControlTreeNode(1,R.id.tvCommonSettingTitle1,0,root);
            ControlTreeNode node11  =new ControlTreeNode(2,R.id.tvCommonSettingTitle11,R.id.tvCommonSettingValue11,node1,ls11,0,4500,"额定电压");
            ControlTreeNode node12  =new ControlTreeNode(2,R.id.tvCommonSettingTitle12,R.id.tvCommonSettingValue12,node1,null,0,4501,"整定电流");
            ControlTreeNode node13  =new ControlTreeNode(2,R.id.tvCommonSettingTitle13,R.id.tvCommonSettingValue13,node1,ls13,0,4502,"互感器");
            ControlTreeNode node2 =new ControlTreeNode(1,R.id.tvCommonSettingTitle2,0,root);
            ControlTreeNode node21  =new ControlTreeNode(2,R.id.tvCommonSettingTitle21,R.id.tvCommonSettingValue21,node2,ls21,0,4509,"过载选择");
            ControlTreeNode node22  =new ControlTreeNode(2,R.id.tvCommonSettingTitle22,R.id.tvCommonSettingValue22,node2,null,2,4510,"定时限过载倍数",0.1f,10);
            ControlTreeNode node23  =new ControlTreeNode(2,R.id.tvCommonSettingTitle23,R.id.tvCommonSettingValue23,node2,null,0,4511,"定时限过载延时",0,1000);
            ControlTreeNode node3  =new ControlTreeNode(1,R.id.tvCommonSettingTitle3,0,root);
            ControlTreeNode node31  =new ControlTreeNode(2,R.id.tvCommonSettingTitle31,R.id.tvCommonSettingValue31,node3,ls31,0,4503,"短路开关");
            ControlTreeNode node32  =new ControlTreeNode(2,R.id.tvCommonSettingTitle32,R.id.tvCommonSettingValue32,node3,null,2,4504,"短路倍数",0.1f,10);
            ControlTreeNode node33  =new ControlTreeNode(2,R.id.tvCommonSettingTitle33,R.id.tvCommonSettingValue33,node3,null,0,4505,"短路延时",0,5000);
            ControlTreeNode node4 =new ControlTreeNode(1,R.id.tvCommonSettingTitle4,0,root);
            ControlTreeNode node41  =new ControlTreeNode(2,R.id.tvCommonSettingTitle41,R.id.tvCommonSettingValue41,node4,ls41,0,4512,"不平衡保护");
            ControlTreeNode node42  =new ControlTreeNode(2,R.id.tvCommonSettingTitle42,R.id.tvCommonSettingValue42,node4,null,0,4513,"不平衡系数",10,100);
            ControlTreeNode node43  =new ControlTreeNode(2,R.id.tvCommonSettingTitle43,R.id.tvCommonSettingValue43,node4,null,0,4514,"不平衡延时",0,500);

            /*****5*****/
            ControlTreeNode node5  =new ControlTreeNode(1,R.id.tvCommonSettingTitle5,0,root);
            ControlTreeNode node51  =new ControlTreeNode(2,R.id.tvCommonSettingTitle51,R.id.tvCommonSettingValue51,node5,ls51,0,4515,"低压侧故障开关");
            ControlTreeNode node52  =new ControlTreeNode(2,R.id.tvCommonSettingTitle52,R.id.tvCommonSettingValue52,node5,ls52,0,4516,"低压侧故障选择");
            ControlTreeNode node53  =new ControlTreeNode(2,R.id.tvCommonSettingTitle53,R.id.tvCommonSettingValue53,node5,null,0,4517,"动作延时",0,1000);
            /*****6*****/
            ControlTreeNode node6  =new ControlTreeNode(1,R.id.tvCommonSettingTitle6,0,root);
            ControlTreeNode node61  =new ControlTreeNode(2,R.id.tvCommonSettingTitle61,R.id.tvCommonSettingValue61,node6,ls61,0,4518,"过压开关");
            ControlTreeNode node62  =new ControlTreeNode(2,R.id.tvCommonSettingTitle62,R.id.tvCommonSettingValue62,node6,null,0,4519,"过压系数",100,140);
            ControlTreeNode node63  =new ControlTreeNode(2,R.id.tvCommonSettingTitle63,R.id.tvCommonSettingValue63,node6,null,0,4520,"过压延时",0,200);
            /*****7*****/
            ControlTreeNode node7  =new ControlTreeNode(1,R.id.tvCommonSettingTitle7,0,root);
            ControlTreeNode node71  =new ControlTreeNode(2,R.id.tvCommonSettingTitle71,R.id.tvCommonSettingValue71,node7,ls71,0,4521,"欠压保护");
            ControlTreeNode node72  =new ControlTreeNode(2,R.id.tvCommonSettingTitle72,R.id.tvCommonSettingValue72,node7,null,0,4522,"欠压系数",65,100);
            ControlTreeNode node73  =new ControlTreeNode(2,R.id.tvCommonSettingTitle73,R.id.tvCommonSettingValue73,node7,null,0,4523,"欠压延时");

            /*****B*****/
            ControlTreeNode node8  =new ControlTreeNode(1,R.id.tvCommonSettingTitle8,0,root);
            ControlTreeNode node81  =new ControlTreeNode(2,R.id.tvCommonSettingTitle81,R.id.tvCommonSettingValue81,node8,ls81,0,4537,"绝缘监视");
            ControlTreeNode node82  =new ControlTreeNode(2,R.id.tvCommonSettingTitle82,R.id.tvCommonSettingValue82,node8,ls82,0,4538,"绝缘保护");
            ControlTreeNode node83  =new ControlTreeNode(2,R.id.tvCommonSettingTitle83,R.id.tvCommonSettingValue83,node8,null,0,4539,"动作延时",0,200);

            /*****9*****/
            ControlTreeNode node9  =new ControlTreeNode(1,R.id.tvCommonSettingTitle9,0,root);
            ControlTreeNode node91  =new ControlTreeNode(2,R.id.tvCommonSettingTitle91,R.id.tvCommonSettingValue91,node9,ls91,0,4524,"温度选择");
            ControlTreeNode node92  =new ControlTreeNode(2,R.id.tvCommonSettingTitle92,R.id.tvCommonSettingValue92,node9,null,0,4525,"温度设置",50,200);
            ControlTreeNode node93  =new ControlTreeNode(2,R.id.tvCommonSettingTitle93,R.id.tvCommonSettingValue93,node9,null,0,4526,"动作延时",0,200);
            ControlTreeNode node94  =new ControlTreeNode(2,R.id.tvCommonSettingTitle94,R.id.tvCommonSettingValue94,node9,ls94,0,4527,"接线柱温度保护");
            ControlTreeNode node95  =new ControlTreeNode(2,R.id.tvCommonSettingTitle95,R.id.tvCommonSettingValue95,node9,null,0,4528,"接线柱温设置",50,200);
            ControlTreeNode node96  =new ControlTreeNode(2,R.id.tvCommonSettingTitle96,R.id.tvCommonSettingValue96,node9,null,0,4529,"动作延时",0,200);
            /*****A*****/
            ControlTreeNode nodeA  =new ControlTreeNode(1,R.id.tvCommonSettingTitleA,0,root);
            ControlTreeNode nodeA1  =new ControlTreeNode(2,R.id.tvCommonSettingTitleA1,R.id.tvCommonSettingValueA1,nodeA,lsA1,0,4530,"风电选择");
            ControlTreeNode nodeA2  =new ControlTreeNode(2,R.id.tvCommonSettingTitleA2,R.id.tvCommonSettingValueA2,nodeA,null,0,4531,"风电延时",0,200);
            ControlTreeNode nodeA3  =new ControlTreeNode(2,R.id.tvCommonSettingTitleA3,R.id.tvCommonSettingValueA3,nodeA,lsA3,0,4532,"瓦斯选择");
            ControlTreeNode nodeA4  =new ControlTreeNode(2,R.id.tvCommonSettingTitleA4,R.id.tvCommonSettingValueA4,nodeA,null,0,4533,"瓦斯延时",0,200);
            ControlTreeNode nodeA5  =new ControlTreeNode(2,R.id.tvCommonSettingTitleA5,R.id.tvCommonSettingValueA5,nodeA,lsA5,0,4508,"断相开关");


            /****B*****/
            ControlTreeNode nodeB  =new ControlTreeNode(1,R.id.tvCommonSettingTitleB,0,root);
            ControlTreeNode nodeB1  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB1,R.id.tvCommonSettingValueB1,nodeB,lsB1,3,5555,"类型");
            ControlTreeNode nodeB2  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB2,R.id.tvCommonSettingValueB2,nodeB,null,3,true);
            ControlTreeNode nodeB3  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB3,R.id.tvCommonSettingValueB3,nodeB,lsB3,3,5555,"级数");
            ControlTreeNode nodeB4  =new ControlTreeNode(2,R.id.tvCommonSettingTitleB4,R.id.tvCommonSettingValueB4,nodeB,lsB4,3,5555,"防越级保护",0,200);









            ControlTreeNode[] root1Children =new ControlTreeNode[]{node11,node12,node13};
            ControlTreeNode[] root2Children = new ControlTreeNode[]{node21,node22,node23};
            ControlTreeNode[] root3Children =new ControlTreeNode[]{node31,node32,node33};
            ControlTreeNode[] root4Children =new ControlTreeNode[]{node41,node42,node43};
            ControlTreeNode[] root5Children = new ControlTreeNode[]{node51,node52,node53};
            ControlTreeNode[] root6Children = new ControlTreeNode[]{node61,node62,node63};
            ControlTreeNode[] root7Children = new ControlTreeNode[]{node71,node72,node73};
            ControlTreeNode[] root8Children =new ControlTreeNode[]{node81,node82,node83};
            ControlTreeNode[] root9Children =new ControlTreeNode[]{node91,node92,node93,node94,node95,node96};
            ControlTreeNode[] rootAChildren =new ControlTreeNode[]{nodeA1,nodeA2,nodeA3,nodeA4,nodeA5};
            ControlTreeNode[] rootBChildren = new ControlTreeNode[]{nodeB1,nodeB2,nodeB3,nodeB4};
            ControlTreeNode[] rootChildren = new ControlTreeNode[]{node1,node2,node3,node4,node5,node6,node7,node8,node9,nodeA,nodeB};

            setLeftAndRight(root1Children);
            setLeftAndRight(root2Children);
            setLeftAndRight(root3Children);
            setLeftAndRight(root4Children);
            setLeftAndRight(root5Children);
            setLeftAndRight(root6Children);
            setLeftAndRight(root7Children);
            setLeftAndRight(root8Children);
            setLeftAndRight(root9Children);
            setLeftAndRight(rootAChildren);
            setLeftAndRight(rootBChildren);
            setLeftAndRight(rootChildren);

            addChild(node1,root1Children);
            addChild(node2,root2Children);
            addChild(node3,root3Children);
            addChild(node4,root4Children);
            addChild(node5,root5Children);
            addChild(node6,root6Children);
            addChild(node7,root7Children);
            addChild(node8,root8Children);
            addChild(node9,root9Children);
            addChild(nodeA,rootAChildren);
            addChild(nodeB,rootBChildren);
            addChild(root,rootChildren);

        }
        return CommonSettingControlTree;
    }

    public static ControlTree getExceptionLog()
    {
        if(ExceptionLog == null){
            ExceptionLog = new ControlTree();

            ControlTreeNode root = new ControlTreeNode();
            root.setLevel(0);

            ExceptionLog.setRootNode(root);

            ControlTreeNode leftButton =new ControlTreeNode(1,R.id.btnExceptionLogPreview,0,root);
            ControlTreeNode rightButton =new ControlTreeNode(1,R.id.btnExceptionLogNext,0,root);

            leftButton.setRight(rightButton);
            rightButton.setLeft(leftButton);


            root.addChild(leftButton);
            root.addChild(rightButton);
        }

        return ExceptionLog;
    }

    public static ControlTree getFactorySetting(){

        List<DataBean<Integer>> ls52 = new ArrayList<>();
        ls52.add(new DataBean<>("38400",0));
        ls52.add(new DataBean<>("19200",1));
        ls52.add(new DataBean<>("9600",2));
        ls52.add(new DataBean<>("4800",3));
        ls52.add(new DataBean<>("2400",4));
        ls52.add(new DataBean<>("1200",5));







        List<DataBean<Integer>> ls53 = new ArrayList<>();
        ls53.add(new DataBean<>("无",0));
        ls53.add(new DataBean<>("偶",1));
        ls53.add(new DataBean<>("奇",2));

        List<DataBean<Integer>> ls54 = new ArrayList<>();
        ls54.add(new DataBean<>("本机",0));
        ls54.add(new DataBean<>("通讯",1));


        List<DataBean<Integer>> ls26 = new ArrayList<>();
        ls26.add(new DataBean<>("关",0));
        ls26.add(new DataBean<>("开",1));

        if(FactorySetting == null){
            FactorySetting = new ControlTree();

            ControlTreeNode root = new ControlTreeNode(0);
            FactorySetting.setRootNode(root);

            ControlTreeNode node1  =new ControlTreeNode(1,R.id.tvFactorySettingTitle1,0,root);
            ControlTreeNode node11  =new ControlTreeNode(2,R.id.tvFactorySettingTitle11,R.id.tvFactorySettingValueOne11,node1,null,0,4570,"系统电压微调",50,100);
            ControlTreeNode node12  =new ControlTreeNode(2,R.id.tvFactorySettingTitle12,R.id.tvFactorySettingValueOne12,node1,null,0,4571,"A相电流微调",50,100);
            ControlTreeNode node13  =new ControlTreeNode(2,R.id.tvFactorySettingTitle13,R.id.tvFactorySettingValueOne13,node1,null,0,4572,"B相电流微调",50,100);
            ControlTreeNode node14  =new ControlTreeNode(2,R.id.tvFactorySettingTitle14,R.id.tvFactorySettingValueOne14,node1,null,0,4573,"C相电流微调",50,100);
            ControlTreeNode node15  =new ControlTreeNode(2,R.id.tvFactorySettingTitle15,R.id.tvFactorySettingValueOne15,node1,null,0,4574,"温度微调",50,100);
            ControlTreeNode node2  =new ControlTreeNode(1,R.id.tvFactorySettingTitle2,0,root);
            ControlTreeNode node21  =new ControlTreeNode(2,R.id.tvFactorySettingTitle21,R.id.tvFactorySettingValue21,node2,null,3,true);
            ControlTreeNode node22  =new ControlTreeNode(2,R.id.tvFactorySettingTitle22,R.id.tvFactorySettingValue22,node2,null,3,true);
            ControlTreeNode node23  =new ControlTreeNode(2,R.id.tvFactorySettingTitle23,R.id.tvFactorySettingValue23,node2,null,3,true);
            ControlTreeNode node24  =new ControlTreeNode(2,R.id.tvFactorySettingTitle24,R.id.tvFactorySettingValue24,node2,null,3);
            ControlTreeNode node25  =new ControlTreeNode(2,R.id.tvFactorySettingTitle25,R.id.tvFactorySettingValue25,node2,null,3,true);
            ControlTreeNode node26  =new ControlTreeNode(2,R.id.tvFactorySettingTitle26,R.id.tvFactorySettingValue26,node2,ls26,3);

            ControlTreeNode node3  =new ControlTreeNode(1,R.id.tvFactorySettingTitle3,0,root);
            ControlTreeNode node31  =new ControlTreeNode(2,R.id.tvFactorySettingTitle31,R.id.tvFactorySettingValue31,node3,getDeviceList(),3,true);
            ControlTreeNode node32  =new ControlTreeNode(2,R.id.tvFactorySettingTitle32,R.id.tvFactorySettingValue32,node3,getBaud(),3,true);
            ControlTreeNode node33  =new ControlTreeNode(2,R.id.tvFactorySettingTitle33,R.id.tvFactorySettingValue33,node3,getCheck(),3,true);
            ControlTreeNode node34  =new ControlTreeNode(2,R.id.tvFactorySettingTitle34,R.id.tvFactorySettingValue34,node3,getDeviceList(),3);
            ControlTreeNode node35  =new ControlTreeNode(2,R.id.tvFactorySettingTitle35,R.id.tvFactorySettingValue35,node3,getBaud(),3);
            ControlTreeNode node36  =new ControlTreeNode(2,R.id.tvFactorySettingTitle36,R.id.tvFactorySettingValue36,node3,getCheck(),3);
            ControlTreeNode node37  =new ControlTreeNode(2,R.id.tvFactorySettingTitle37,R.id.tvFactorySettingValue37,node3,null,3);

            ControlTreeNode node4  =new ControlTreeNode(1,R.id.tvFactorySettingTitle4,0,root);
            ControlTreeNode node41  =new ControlTreeNode(2,R.id.tvFactorySettingTitle41,0,node4,null,5);
            ControlTreeNode node42  =new ControlTreeNode(2,R.id.tvFactorySettingTitle42,0,node4,null,5);
            ControlTreeNode node43  =new ControlTreeNode(2,R.id.tvFactorySettingTitle43,0,node4,null,5);
            ControlTreeNode node44  =new ControlTreeNode(2,R.id.tvFactorySettingTitle44,0,node4,null,5);
            ControlTreeNode node45  =new ControlTreeNode(2,R.id.tvFactorySettingTitle45,0,node4,null,5);
            ControlTreeNode node46  =new ControlTreeNode(2,R.id.tvFactorySettingTitle46,0,node4,null,5);

            ControlTreeNode node5  =new ControlTreeNode(1,R.id.tvFactorySettingTitle5,0,root);
            ControlTreeNode node51  =new ControlTreeNode(2,R.id.tvFactorySettingTitle51,R.id.tvFactorySettingValue51,node5,null,0,4550,"485站地址",1,250);
            ControlTreeNode node52  =new ControlTreeNode(2,R.id.tvFactorySettingTitle52,R.id.tvFactorySettingValue52,node5,ls52,0,4551,"波特率");
            ControlTreeNode node53  =new ControlTreeNode(2,R.id.tvFactorySettingTitle53,R.id.tvFactorySettingValue53,node5,ls53,0,4552,"校验");
            ControlTreeNode node54  =new ControlTreeNode(2,R.id.tvFactorySettingTitle54,R.id.tvFactorySettingValue54,node5,ls54,0,4553,"远程控制开关");

            ControlTreeNode node6  =new ControlTreeNode(1,R.id.tvFactorySettingTitle6,0,root);
            ControlTreeNode node61  =new ControlTreeNode(2,R.id.tvFactorySettingTitle61,0,node6,null,5);
            ControlTreeNode node62  =new ControlTreeNode(2,R.id.tvFactorySettingTitle62,0,node6,null,5);



            ControlTreeNode[] rootChildren = new ControlTreeNode[]{node1,node2,node3,node4,node5,node6};
            ControlTreeNode[] node1Children = new ControlTreeNode[]{node11,node12,node13,node14,node15};
            ControlTreeNode[] node2Children = new ControlTreeNode[]{node21,node22,node23,node24,node25,node26};
            ControlTreeNode[] node3Children = new ControlTreeNode[]{node31,node32,node33,node34,node35,node36,node37};
            ControlTreeNode[] node4Children = new ControlTreeNode[]{node41,node42,node43,node44,node45,node46};
            ControlTreeNode[] node5Children = new ControlTreeNode[]{node51,node52,node53,node54};
            ControlTreeNode[] node6Children = new ControlTreeNode[]{node61,node62};


            setLeftAndRight(node1Children);
            setLeftAndRight(node2Children);
            setLeftAndRight(node3Children);
            setLeftAndRight(node4Children);
            setLeftAndRight(node5Children);
            setLeftAndRight(node6Children);
            setLeftAndRight(rootChildren);

            addChild(node1,node1Children);
            addChild(node2,node2Children);
            addChild(node3,node3Children);
            addChild(node4,node4Children);
            addChild(node5,node5Children);
            addChild(node6,node6Children);
            addChild(root,rootChildren);


        }
        return FactorySetting;
    }

    private static void addChild(ControlTreeNode parentNode,ControlTreeNode[] childrenNode)
    {
        for(int i =0;i< childrenNode.length;i++) {
            parentNode.addChild(childrenNode[i]);
        }
    }

    private static void setLeftAndRight(ControlTreeNode[] nodes)
    {
        for(int i = 0;i<nodes.length;i++)
        {
            int leftIndex = i - 1;
            int rightIndex = i+1;
            if(leftIndex>-1)
            {
                nodes[i].setLeft(nodes[leftIndex]);
            }
            if(rightIndex < nodes.length)
            {
                nodes[i].setRight(nodes[rightIndex]);
            }
        }
    }

    public static ControlTree getSwitch(){
        if(Switch == null){
            Switch = new ControlTree();

            ControlTreeNode root = new ControlTreeNode();
            root.setLevel(0);
            Switch.setRootNode(root);

            ControlTreeNode controlTreeNode1 = new ControlTreeNode(1,R.id.tvSwitchTestTitle1,0,root,3595,"开关合闸",true,2);
            ControlTreeNode controlTreeNode2 = new ControlTreeNode(1,R.id.tvSwitchTestTitle2,0,root,3595,"开关分闸",true,4);
            ControlTreeNode controlTreeNode3 = new ControlTreeNode(1,R.id.tvSwitchTestTitle3,0,root,3595,"短路试验",true,16);
            ControlTreeNode controlTreeNode4 = new ControlTreeNode(1,R.id.tvSwitchTestTitle4,0,root,3595,"过载试验",true,32);
            ControlTreeNode controlTreeNode5 = new ControlTreeNode(1,R.id.tvSwitchTestTitle5,0,root,3595,"不平衡试验",true,8);
            ControlTreeNode controlTreeNode6 = new ControlTreeNode(1,R.id.tvSwitchTestTitle6,0,root);
            ControlTreeNode controlTreeNode7 = new ControlTreeNode(1,R.id.tvSwitchTestTitle7,0,root);
            controlTreeNode7.setNeedClick(true);



            ControlTreeNode[] rootChildren = new ControlTreeNode[]{controlTreeNode1,controlTreeNode2,controlTreeNode3,controlTreeNode4,controlTreeNode5,controlTreeNode6,controlTreeNode7};
            setLeftAndRight(rootChildren);
            addChild(root,rootChildren);
        }
        return Switch;
    }

    private static  List<DataBean<Integer>> getDeviceList()
    {
       String [] arrDevices =   new SerialPortFinder().getAllDevicesPath();
        List<DataBean<Integer>> ls = new ArrayList<>();
        int index = 0;
        for(String devices : arrDevices){
            ls.add(new DataBean<>(devices,index));
        }

        return ls;
    }

    private static  List<DataBean<Integer>> getBaud()
    {
        List<DataBean<Integer>> ls = new ArrayList<>();
        ls.add(new DataBean<>("1200",1200));
        ls.add(new DataBean<>("2400",2400));
        ls.add(new DataBean<>("4800",4800));
        ls.add(new DataBean<>("9600",9600));
        ls.add(new DataBean<>("19200",19200));
        ls.add(new DataBean<>("38400",38400));
        ls.add(new DataBean<>("57600",57600));
        ls.add(new DataBean<>("115200",115200));
        return ls;
    }

    private static List<DataBean<Integer>> getCheck(){
        List<DataBean<Integer>> ls = new ArrayList<>();
        ls.add(new DataBean<>("无",0));
        ls.add(new DataBean<>("奇",1));
        ls.add(new DataBean<>("偶",2));
        return ls;
    }
}
